package service

import (
	"context"
	"fmt"
	"video-srv/basic/config"
	__ "video-srv/basic/proto"
	"video-srv/handler/model"
)

func (s *Server) DramaAdd(_ context.Context, in *__.DramaAddReq) (*__.DramaAddResp, error) {
	//参数校验
	if in.Titles == "" || in.TypeOs == "" || in.Producer == "" {
		return nil, fmt.Errorf("电视剧参数不能为空")
	}
	dram := model.Drama{
		Titles:   in.Titles,
		TypeOs:   in.TypeOs,
		Producer: in.Producer,
	}
	config.DB.Create(&dram)
	return &__.DramaAddResp{
		DramId: int64(dram.ID),
	}, nil
}
